const express = require('express')
const route = express.Router()
const adminModel = require('../db/modle/adminModel')
const isLoginMiddle = require('../middleware/isLoginMiddle')
route.delete('/deleteAdmin', isLoginMiddle,async (req, res) => {
    const {
        adminName
    } = req.query
    try {
        const re = await adminModel.deleteOne({
            adminName
        })

        if (re.deletedCount > 0) {
            return res.send({
                code: 10000,
                message: "删除成功"
            })
        }
        res.send({
            code: 10001,
            message: "删除失败"
        })


    } catch (e) {
        console.log('删除异常'+e.message);
        res.send({
            code: 10001,
            message: e.message + "删除失败"
        })
    }
})
module.exports = route